package com.advertise.model;

import java.util.HashSet;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;



@Entity
@Table(name = "role")

public class Role {
	private int roleId;
	private String roleName;
	private String roleDesc;
	private Set<Menu> roleMenus = new HashSet<Menu>(0);
	
	private Set<User> roleUsers = new HashSet<User>(0);
	
	
	@ManyToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="roles")
	
	public Set<User> getRoleUsers() {
		return roleUsers;
	}
	public void setRoleUsers(Set<User> roleUsers) {
		this.roleUsers = roleUsers;
	}
	
	@ManyToMany( cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="roles")
			
	public Set<Menu> getRoleMenus() {
		return roleMenus;
	}
	public void setRoleMenus(Set<Menu> roleMenus) {
		this.roleMenus = roleMenus;
	}
	
	@Id
	@Column(name="roleId",unique=true,nullable = false)
	public int getRoleId() {
		return roleId;
	}
	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}
	public String getRoleName() {
		return roleName;
	}
	
	@Column(name="roleName")
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
	public String getRoleDesc() {
		return roleDesc;
	}
	
	@Column(name="roleDesc")
	public void setRoleDesc(String roleDesc) {
		this.roleDesc = roleDesc;
	}
	
}
